import { registerAs } from "@nestjs/config";
import { TypeOrmModuleOptions } from "@nestjs/typeorm";

export default registerAs(
	"database",
	(): TypeOrmModuleOptions => ({
		type: "mysql",
		host: process.env.DB_HOST || "localhost",
		port: parseInt(process.env.DB_PORT) || 3306,
		username: process.env.DB_USERNAME || "root",
		password: process.env.DB_PASSWORD || "root",
		database: process.env.DB_DATABASE || "points_db",
		entities: [__dirname + "/../**/*.entity{.ts,.js}"],
		synchronize: process.env.DB_SYNCHRONIZE === "true",
		logging: process.env.NODE_ENV === "development",
		dateStrings: ["DATE", "DATETIME", "TIMESTAMP"],
		timezone: "+08:00",
		autoLoadEntities: true,
	})
);
